package com.haitonghop.main;

import java.util.ArrayList;

import com.haitonghop.R;
import com.haitonghop.data.HaiBLModule;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class HaiBLModulesRenderAdapter extends ArrayAdapter<HaiBLModule> {

	ArrayList<HaiBLModule> blockList = null;

	public HaiBLModulesRenderAdapter(Context context, int resource, int textViewResourceId, ArrayList<HaiBLModule> objects) {
		super(context, resource, textViewResourceId, objects);
		this.blockList = objects;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub

		LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowHeader = inflater.inflate(R.layout.haibl_render_modules, parent, false);
		TextView header = (TextView) rowHeader.findViewById(R.id.nameView);
		ImageView avatar = (ImageView) rowHeader.findViewById(R.id.avatarView);
		
		HaiBLModule module = this.blockList.get(position);
		header.setText(module.getName());
		
		if(module.getId() == HaiBLModule.HAIVL){
			avatar.setImageResource(R.drawable.haivl);
		} else if(module.getId() == HaiBLModule.CABVN){
			avatar.setImageResource(R.drawable.cabo_modules);
		} else if(module.getId() == HaiBLModule.EPICVN){
			avatar.setImageResource(R.drawable.epic);
		} else if(module.getId() == HaiBLModule.TAMDIEM){
			avatar.setImageResource(R.drawable.store);
		} else if(module.getId() == HaiBLModule.OHVUI){
			avatar.setImageResource(R.drawable.hot);
		} 
//		else if(module.getId() == HaiBLModule.QUAYBAO){
//			avatar.setImageResource(R.drawable.newsstand);
//		}
		else{
			avatar.setImageResource(R.drawable.contact);
		}
		return rowHeader;
	}



}
